package com.sora.sora.manager.controller;

import com.sora.sora.common.model.vo.ResultVO;
import com.sora.sora.common.utils.ResponseResult;
import com.sora.sora.manager.service.SysImgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "图片管理", tags = "图片管理模块")
@RestController
@RequestMapping("sys/img")
public class SysImgController {

    @Resource
    SysImgService sysImgService;

    @Resource
    ResponseResult responseResult;


    @ApiOperation(value = "根据图片id批量删除图片")
    @ApiResponses({
            @ApiResponse(code = 200, message = "删除成功"),
            @ApiResponse(code = 1002, message = "删除失败并返回失败的图片id")
    })
    @DeleteMapping
    public ResultVO delImg(int[] imgIds) {
        List<Integer> list = sysImgService.deletedImg(imgIds);
        return list.isEmpty() ? responseResult.ok() : responseResult.faile(list);
    }
}
